package com.heatingcharge.mapper.sys;

import com.heatingcharge.entity.sys.SysMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 菜单权限表 Mapper 接口
 * </p>
 *
 * @author devin.jiang
 * @since 2019-06-27
 */
public interface SysMenuMapper extends BaseMapper<SysMenu> {
    @Select("select m.perms from sys_menu m, sys_user u, sys_role_menu rm\n" +
            "        where u.id = #{user_id} \n" +
            "          and u.role_id = rm.role_id and rm.menu_id = m.id")
    List<String> findPermsByUserId(Integer userId);

    @Select("select rm.menu_id from sys_role_menu rm\n" +
            "        where rm.role_id = #{role_id}")
    List<Integer> findMenuIdsByRoleId(Integer roleId);
}
